# Cmake配置
#https://developer.android.google.cn/studio/projects/configure-cmake
#https://www.jianshu.com/p/c71ec5d63f0d
#官方指导 https://d.android.com/studio/projects/add-native-code.html
#cmake参考手册 https://cmake.org/cmake/help/v3.0/index.html

# 安装的cmake最小版本
cmake_minimum_required(VERSION 3.10.2)

# 指定项目名称
project("ffmpegtest")

# set设置变量
# 官方标准配置
# CMAKE_C_FLAGS 配置C编译选项
# -Wall 编译后显示所有警告。
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
# CMAKE_CXX_FLAGS 配置C++编译选项
# -std=c++11 采用C++2011标准
# -fno-rtti 禁用运行时类型信息
# -fno-exceptions 禁用异常机制
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions -Wall")

#ANDROID_PLATFORM_LEVEL=18 android5.0以上的手机开始支持opengl es 3.0
add_definitions("-DDYNAMIC_ES3")
set(OPENGL_LIB GLESv3)

# libs路径
set(LIBS_DIR ${CMAKE_SOURCE_DIR}/../../../libs)
# abi对应的so库路径
set(JNI_LIBS_DIR ${LIBS_DIR}/${ANDROID_ABI})
# 加载预编译好的so库，这样就可以不用一个一个去导入
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${JNI_LIBS_DIR} ")
# 导入libs/include头文件
include_directories(${LIBS_DIR}/include)

# 载入当前文件路径所在文件夹中所有cpp文件
#file(GLOB SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_library(
        GLV3Renderer-lib

        SHARED

        GLV3Renderer-lib.cpp
        utils/FormatUtils.cpp
        utils.cpp
        BlurPicture.cpp
)
# 为目标（GLV3Renderer-lib）导入头文件 path=...../cpp/include
target_include_directories(
        GLV3Renderer-lib
        PRIVATE
        ${CMAKE_SOURCE_DIR}/include
)
# 查找本地库
find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)
#将预构建的库添加到自己的原生库
target_link_libraries( # Specifies the target library.
        #        native-lib
        GLV3Renderer-lib
        android
        EGL
        ${OPENGL_LIB}#GLES v3版本库
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})